{
	template:`
	<div style="min-height:300px;">
	<div v-if="mainInit" style="position:fixed;width:100%;height:100%;top:0px;left:0px;overflow-y:auto;overflow-x:hidden;">
		<div class="index-head" style="position:fixed;z-index:2;width:100%;padding-bottom:16px;">
			<div style="float:left;color:#fff;padding:0 10px;">
				<a-row type="flex" :gutter="5">
					<a-col v-if="'YA'.indexOf(system.titleType)>=0"><img :src="system.titleIcon.path" height="62" /></a-col>
					<a-col v-if="'NA'.indexOf(system.titleType)>=0" style="font-size:18px;line-height:62px;"><span v-text="system.backgroundTitle"></span></a-col>
				</a-row>
			</div>
			<div style="float:right;color:#fff;padding:10px 10px 0;cursor:pointer;">
				<a-dropdown>
					<a-row type="flex" :gutter="5">
						<a-col><a-avatar size="large" :src="login.headImage.thumPath"></a-avatar></a-col>
						<a-col>
							<div>
							    <span v-text="login.realname"></span>
							    <span v-if="assist&&assist.oid">({{assist.realname}})</span>
							</div>
							<small v-if="org.oid" v-text="org.org.name+(org.dept.oid!=org.oid?'/'+org.dept.name:'')+'/'+org.name"></small>
							<small v-else v-text="login.adminGroup.name"></small>
						</a-col>
						<a-col style="padding-top:10px;"><m-icon size="19" name="icon-moreunfold"></m-icon></a-col>
					</a-row>
					<template #overlay>
						<a-menu>
							<a-menu-item v-if="!(assist&&assist.oid)" @click="modifySelf"><m-icon name="icon-survey"/>&nbsp;修改登陆信息</a-menu-item>
							<a-menu-item v-if="!(assist&&assist.oid)&&setting.assistLogin=='Y'" @click="myAdminAssistList"><m-icon name="icon-bussinesscard"/>&nbsp;外协账号管理</a-menu-item>
							<a-sub-menu v-if="!(assist&&assist.oid)&&orgGroups.length&&orgGroups.length>1">
								<template #title><m-icon name="icon-process"/>&nbsp;选择机构</template>
								<a-menu-item v-for="(item,index) in orgGroups" :key="index" @click="setCurrentOrgGroup(item)">{{item.org.name}}{{item.oid!=item.dept.oid?'/'+item.dept.name:''}}/{{item.name}}<small style="color:#1890ff;">{{org.oid==item.oid?'(当前)':''}}</small></a-menu-item>
							</a-sub-menu>
							<a-sub-menu>
								<template #title><m-icon name="icon-color"/>&nbsp;主题</template>
								<a-menu-item @click="setPageTheme('')">默认主题<small style="color:#1890ff;">{{setting.theme==''?'(当前)':''}}</small></a-menu-item>
								<a-menu-item @click="setPageTheme('dark')">黑暗主题<small style="color:#1890ff;">{{setting.theme=='dark'?'(当前)':''}}</small></a-menu-item>
							</a-sub-menu>
							<a-menu-divider></a-menu-divider>
							<a-menu-item @click="logout"><m-icon name="icon-icon-132"/>&nbsp;退出系统</a-menu-item>
						</a-menu>
					</template>
				</a-dropdown>
			</div>
            <div v-if="modules" style="float:right;cursor:pointer;">
                <a-space>
                    <template v-for="(module,key) in modules">
                        <a-popover v-if="module.type=='B'">
                            <span style="color: hsla(0,0%,100%,.65);line-height:62px;" @click="module.link?changeModule(module):'';">
                                <span :style="{color:(activeModule==key?'#3af':'')}">
                                    <m-icon :name="module.icon" :size="19"></m-icon>
                                    <span style="padding-left:5px;font-size:14px;" v-text="module.name"></span>
                                </span>
                                <a-badge v-if="remindMap[module.oid]" :count="remindMap[module.oid]"><span style="line-height:20px;">&nbsp;</span></a-badge>
                            </span>
                            <template #content>
                                <div v-if="!module.menus">{{module.name}}</div>
                                <template v-for="(menu1,k1) in module.menus">
                                    <div v-if="menu1.link" @click="changeModule(module);changeMenu(menu1);" style="padding:5px 0px;cursor:pointer;">
                                        <m-icon v-if="menu1.icon" :color="isChangeMenu(menu1.oid)?'#1890ff':''" size="17" :name="menu1.icon"></m-icon>
                                        <m-icon v-else :color="isChangeMenu(menu1.oid)?'#1890ff':''" name="icon-icon-62"></m-icon>
                                        <span class="span-link" style="padding-left:5px;" :style="{color:isChangeMenu(menu1.oid)?'#1890ff':''}" v-text="menu1.name"></span>
                                        <a-badge v-if="remindMap[menu1.oid]" :count="remindMap[menu1.oid]"><span style="line-height:15px;">&nbsp;</span></a-badge>
                                    </div>
                                    <div v-else style="padding:5px 0px;cursor:pointer;">
                                        <m-icon v-if="menu1.icon" :color="isChangeMenu(menu1.oid)?'#1890ff':''" size="17" :name="menu1.icon"></m-icon>
                                        <m-icon v-else :color="isChangeMenu(menu1.oid)?'#1890ff':''" name="icon-icon-62"></m-icon>
                                        <span style="padding-left:5px;" :style="{color:isChangeMenu(menu1.oid)?'#1890ff':''}" v-text="menu1.name"></span>
                                        <a-badge v-if="remindMap[menu1.oid]" :count="remindMap[menu1.oid]"><span style="line-height:15px;">&nbsp;</span></a-badge>
                                    </div>
                                    <div v-for="(menu2,k2) in menu1.menus" @click="changeModule(module);changeMenu(menu2)" style="padding:5px 0 5px 16px;cursor:pointer;">
                                        <m-icon v-if="menu2.icon" :color="isChangeMenu(menu2.oid)?'#1890ff':''" :name="menu2.icon"></m-icon>
                                        <m-icon v-else name="icon-icon-62" :color="isChangeMenu(menu2.oid)?'#1890ff':''"></m-icon>
                                        <span class="span-link" style="padding-left:5px;" v-text="menu2.name" :style="{color:isChangeMenu(menu2.oid)?'#1890ff':''}"></span>
                                        <a-badge v-if="remindMap[menu2.oid]" :count="remindMap[menu2.oid]"><span style="line-height:15px;">&nbsp;</span></a-badge>
                                    </div>
                                </template>
                            </template>
                        </a-popover>
                    </template>
                </a-space>
            </div>
			<a-menu v-if="modules" mode="horizontal" theme="dark" :selected-keys="activeModule" :style="{background:'transparent',lineHeight:'60px'}">
				<template v-for="(module,key) in modules">
				<a-menu-item v-if="module.type=='A'" @click="changeModule(module)" :key="key">
					<div>
						<m-icon :name="module.icon" :size="19"></m-icon>
						<span style="padding-left:5px;" v-text="module.name"></span>
						<a-badge v-if="remindMap[module.oid]" :count="remindMap[module.oid]"><span style="line-height:20px;">&nbsp;</span></a-badge>
					</div>
				</a-menu-item>
				</template>
			</a-menu>
		</div>
        <a-layout class="index-main" style="position: fixed;width: 100%;top: 60px;border-radius: 16px 16px 0 0;z-index: 2;">
            <a-layout-sider class="index-menu" v-if="modules&&inlineMenu" :width="menuWidth">
                <template v-for="(module,key) in modules">
                <div v-if="module.type=='A'" :class="[activeModule==key?'animate-bottom-show':'animate-bottom-hidden']" :style="{width:menuWidth}" style="position: fixed;overflow-y:auto;height:calc(100vh - 62px);padding-top:13px;">
                    <a-menu mode="inline" :selected-keys="activeMenu" v-model:open-keys="openMenus">
                        <template v-for="(menu1,k1) in module.menus">
                            <a-sub-menu v-if="menu1.menus" :key="k1">
                                <template #title>
                                    <div @click="changeMenu(menu1)">
                                        <m-icon v-if="menu1.icon" size="19" :name="menu1.icon"></m-icon>
                                        <m-icon v-else name="icon-icon-62"></m-icon>
                                        <span style="padding-left:5px;" v-text="menu1.name"></span>
                                        <a-badge v-if="remindMap[menu1.oid]" :count="remindMap[menu1.oid]"><span style="line-height:15px;">&nbsp;</span></a-badge>
                                    </div>
                                </template>
                                <a-menu-item v-for="(menu2,k2) in menu1.menus" :key="k2" @click="changeMenu(menu2)">
                                    <m-icon v-if="menu2.icon" size="19" :name="menu2.icon"></m-icon>
                                    <m-icon v-else name="icon-icon-62"></m-icon>
                                    <span style="padding-left:5px;" v-text="menu2.name"></span>
                                    <a-badge v-if="remindMap[menu2.oid]" :count="remindMap[menu2.oid]"><span style="line-height:15px;">&nbsp;</span></a-badge>
                                </a-menu-item>
                            </a-sub-menu>
                            <template v-else>
                                <a-menu-item @click="changeMenu(menu1)" :key="k1">
                                    <m-icon v-if="menu1.icon" size="19" :name="menu1.icon"></m-icon>
                                    <m-icon v-else name="icon-icon-62"></m-icon>
                                    <span style="padding-left:5px;" v-text="menu1.name"></span>
                                    <a-badge v-if="remindMap[menu1.oid]" :count="remindMap[menu1.oid]"><span style="line-height:15px;">&nbsp;</span></a-badge>
                                </a-menu-item>
                            </template>
                        </template>
                    </a-menu>
                </div>
                </template>
            </a-layout-sider>
            <a-layout-sider class="index-menu" v-if="modules&&!inlineMenu" :width="menuWidth">
                <template v-for="(module,key) in modules">
                <div v-if="module.type=='A'" :key="key" :class="activeModule==key?'animate-bottom-show':'animate-bottom-hidden'" :style="{width:menuWidth}" style="position: fixed;overflow-y:auto;height:calc(100vh - 62px);padding-top:13px;">
                    <a-popover v-for="(menu1,k1) in module.menus" placement="rightTop" :mouse-enter-delay="menu1.menus?0:1000">
                        <div @click="changeMenu(menu1)" style="text-align:center;line-height:1.3;padding:9px 0;cursor:pointer;">
                            <m-icon v-if="menu1.icon" size="35" :color="isChangeMenu(menu1.oid)?'#1890ff':''" :name="menu1.icon"></m-icon>
                            <m-icon v-else name="icon-skip" size="35" :color="isChangeMenu(menu1.oid)?'#1890ff':''"></m-icon>
                            <a-badge v-if="remindMap[menu1.oid]" :count="remindMap[menu1.oid]"><span style="line-height:15px;">&nbsp;</span></a-badge>
                            <div v-text="menu1.name" :style="{color:isChangeMenu(menu1.oid)?'#1890ff':''}"></div>
                        </div>
                        <template #content>
                            <div v-for="(menu2,k2) in menu1.menus" @click="changeMenu(menu2)" style="padding:3px 8px;cursor:pointer;">
                                <m-icon v-if="menu2.icon" size="19" :color="isChangeMenu(menu2.oid)?'#1890ff':''" :name="menu2.icon"></m-icon>
                                <m-icon v-else name="icon-icon-62" :color="isChangeMenu(menu2.oid)?'#1890ff':''"></m-icon>
                                <span style="padding-left:5px;" v-text="menu2.name" :style="{color:isChangeMenu(menu2.oid)?'#1890ff':''}"></span>
                                <a-badge v-if="remindMap[menu2.oid]" :count="remindMap[menu2.oid]"><span style="line-height:15px;">&nbsp;</span></a-badge>
                            </div>
                        </template>
                    </a-popover>
                </div>
                </template>
            </a-layout-sider>
            <a-layout-content :style="{height:'100vh',paddingTop:'2px'}">
                <div class="index-tabs" style="position:fixed;z-index:2;" :style="{width:'calc(100vw - '+menuWidth+')'}">
                    <a-tabs :active-key="activeTab" :tab-bar-style="{margin:'5px 5px 0px 10px'}" type="editable-card" @edit="removeTabMenu" @change="tabChange" :hide-add="true" size="small">
                        <template #leftExtra>
                            <a-button ghost type="text" v-if="menuWidth!='0px'" style="margin-left:-5px;padding:4px 7px;" @click="inlineMenu=!inlineMenu;resetMenuWidth();">
                                <m-icon size="18" :name="inlineMenu?'icon-icon-2':'icon-icon-75'"></m-icon>
                            </a-button>
                            <a-button ghost type="text" v-else style="margin-left:-5px;padding:4px 7px;">
                                <m-icon size="18" name="icon-jifen"></m-icon>
                            </a-button>
                        </template>
                        <a-tab-pane v-for="(item, index) in tabMenus" :key="index" :tab="item" :closable="activeTab==index&&hasTabMenu()" style="height:calc(100vh - 106px);overflow:auto;overflow-x:hidden;margin-top: -1px;padding:0 0 0 3px;">
                            <div :class="[activeTab==index?'animate-show':'animate-hidden','index-tabspane-'+setting.theme]" :id="'page_'+index" style="border-radius: 9px 0 0 3px;">
                                <div style="padding:30px;"><a-skeleton /></div>
                            </div>
                        </a-tab-pane>
                    </a-tabs>
                </div>
            </a-layout-content>
        </a-layout>
	</div>
	<div v-else style="padding:100px 30px;">
        <a-spin tip="...加载中..." size="large">
            <div style="height:calc(100vh - 200px);"></div>
        </a-spin>
	</div>
	</div>
	<link v-if="setting.theme" rel="stylesheet" type="text/css" :href="'/resources/common/antd.'+setting.theme+'.min.css'">
	`,
	props: ['localeZh','param','parentVue'],
	data:function(){
		return {
		    setting:{},
			mainInit:false,
            system:{titleIcon:{},backgroundImage:{}},
          	login:{headImage:{},orgGroup:{}},
          	assist:{},
          	org:{},
          	orgGroups:[],
          	inlineMenu:true,menuWidth:"0px",modules:null,menus:null,activeModule:[],activeMenu:[],openMenus:[],menuV3s:{},
          	tabMenus:{},activeTab:'',
          	remindUrl:'',remindMap:{},
		};
	},
	mounted(){
		this.isLogin();
	},
	methods:{
		isLogin:function(){
			this.requestData('action/manage/adminLogin/isLogin',
				{},
				function(data){
					if(data.code==0&&null!=data.model){
						mo.admin=data.model;
						mo.assist=data.assist||{};
						mo.orgGroup=data.orgGroup;
						mo.setting=data.setting;
						mo.powers=data.powers;
						console.log(mo);
						this.setting=mo.setting;
                        document.body.className="index-theme-"+this.setting.theme;
						this.assist=mo.assist;
						this.loadMainInfo();
					}else{
						this.openPage('page/login.js',{codeVerify:data.codeVerify},
							function(flag,obj){
								this.isLogin();
							}.bind(this),"","PAGE"
						)
					}
				}.bind(this)
			);
		},
		loadMainInfo:function(){
			this.system=mo.system;
			this.login=mo.admin;
			this.org=mo.orgGroup||{};
			this.requestData('action/manage/adminGroup/getMyOrgGroup',{},function(json){
				if(json.code==0){
					this.orgGroups=json.list;
				}
				//初始化菜单
				this.requestData('action/manage/groupMenuLink/getModuleList',
					{},
					function(data){
						if(data.code==0){
							this.remindUrl=data.remindUrl;
							this.modules=data.modules;
							this.menus={};
							for(var i in this.modules){
								for(var n in this.modules[i].menus){
									for(var m in this.modules[i].menus[n].menus){
										this.menus[m]=this.modules[i].menus[n].menus[m];
									}
									this.menus[n]=this.modules[i].menus[n];
								}
								this.menus[i]=this.modules[i];
							}
                            var menuOid=mo.fn.getHash()||data.defaultMenuOid||"A0000";
                            this.activeModule=[menuOid.substring(0,1)];
                            this.openMenus=[menuOid.substring(0,3)];
                            this.activeMenu=[menuOid];
							this.resetMenuWidth();
							setTimeout(function(){
							    this.mainInit=true;
                                this.doMenu(menuOid);
							}.bind(this),300);
							if(this.remindUrl){
								setTimeout(this.getRemind,1000);
							}
						}
					}.bind(this)
				);
			}.bind(this));
		},
		getRemind:function(){
			this.requestData(this.remindUrl,{},(function(json){
				if(json.code==0){
					let mm=json.menu||{};
					let m={};
					for(let k in mm){
						let n=isNaN(mm[k])?1:parseInt(mm[k]);
						let k1=k.substr(0,1),k2=k.substr(0,3);
						if(!m[k1]) m[k1]=0;
						m[k1]=m[k1]+n;
						if(!m[k2]) m[k2]=0;
						m[k2]=m[k2]+n;
					}
					for(let k in mm){
						m[k]=mm[k];
					}
					this.remindMap=m;
					setTimeout(this.getRemind,5000);
				}
			}).bind(this),true);
		},
		modifySelf:function(){
			this.openPage('action/manage/adminLogin/toEdit4Self',{},function(){
				location.reload();
			}.bind(),"600px");
		},
		myAdminAssistList:function(){
			this.openPage('action/manage/adminAssist/myAdminAssistList',{},function(){

			}.bind(),"900px");
		},
		setPageTheme:function(te){
            if(te!=this.setting.theme){
				this.requestData("action/manage/adminSetting/setAttr",{name:'theme',value:te},function(json){
				    if(json.code==0){
                        this.setting.theme=te;
                        document.body.className="index-theme-"+this.setting.theme;
                    }
				}.bind(this));
            }
		},
		logout:function(){
			this.$confirm({
				title: '退出系统',
				content: '确定要退出系统吗?',
				onOk: function(){
					this.pageLoad=true;
					this.requestData("action/manage/adminLogin/doLogout",{},function(json){
						document.cookie="admin_name=; expires="+new Date(0).toGMTString();
						document.cookie="admin_key=; expires="+new Date(0).toGMTString();
						window.location.hash="";
						location.reload();
					});
				}.bind(this)
			});
		},
		setCurrentOrgGroup:function(org){
			if(org.oid!=this.login.orgGroup.oid){
				this.$confirm({
					title: '更改当前机构',
					content: '确定要更改为('+org.org.name+(org.dept.oid!=org.oid?('/'+org.parent.name):'')+'/'+org.name+')?',
					onOk: function(){
						this.pageLoad=true;
						this.requestData("action/manage/adminGroup/setCurrentOrgGroup",{model:{oid:org.oid}},function(json){
							window.location.hash="";
							location.reload();
						});
					}.bind(this)
				});
			}
		},
		changeModule:function(obj){
			this.activeModule[0]=obj.oid;
			if(obj.link){
				this.changeMenu(obj);
			}
			this.resetMenuWidth();
		},
		resetMenuWidth:function(){
			var obj=this.modules[this.activeModule[0]];
			if(obj.menus&&obj.type=='A'){
				if(this.inlineMenu){
					this.menuWidth="200px";
				}else{
					this.menuWidth="88px";
				}
			}else{
				this.menuWidth="0px";
			}
		},
		changeMenu:function(obj){
			if(obj.link){
				this.activeMenu[0]=obj.oid;
				location.hash=this.activeMenu[0];
			    this.resetMenuWidth();
			}
		},
		isChangeMenu:function(menuOid){
			if(this.activeMenu.length>0){
				return this.activeMenu[0].indexOf(menuOid)==0;
			}
			return false;
		},
		doMenu:function(key){
			if(!this.tabMenus[key]){
				this.requestData("action/manage/groupMenuLink/gotoMenuPage",{menu:{oid:key}},(data)=>{
					if(data.code==0){
						this.loadPage("page_"+key,data.url,{menuKey:key,isOpen:false},function(pv,v3){
							this.menuV3s[key]=v3;
						}.bind(this));
					}else{
						this.loadPage("page_"+key,'page/error.js',{error:'错误',errorMessage:data.msg,hasBack:false},function(pv,v3){
							this.menuV3s[key]=v3;
						}.bind(this));
					}
				});
			}
			this.tabMenus[key]=this.menus[key].name;
			this.activeTab=key;
		},
		tabChange:function(key){
			this.activeTab=key;
			this.activeModule[0]=key.substring(0,1);
			this.changeMenu(this.menus[key]);
		},
		hasTabMenu:function(){
			var n=0;
		 	for(var i in this.tabMenus){
		 		n++;
		 	}
			return n>1;
		},
		removeTabMenu:function(key){
			delete this.tabMenus[key];
			if(this.menuV3s[key]) {
				setTimeout(()=>{
					this.menuV3s[key].unmount();
				},240);
			}
		 	for(var i in this.tabMenus){
		 		this.changeMenu(this.menus[i]);
		 		return;
		 	}
		}
	}
}